import 'dart:io';

import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';
import 'package:images_picker/images_picker.dart';
import 'package:meal/constant/antd_icons.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/route/route.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

///
/// 商品发布
///
class ProductRelease extends StatefulWidget {
  const ProductRelease({Key? key}) : super(key: key);

  @override
  State<ProductRelease> createState() => _ProductReleaseState();
}

class _ProductReleaseState extends State<ProductRelease> {
  List<Media> imgs = [];

  List<BrnMultiDataPickerEntity> types = [];

  bool delivery = false;

  bool meal = true;

  bool timeLimit = false;

  bool limited = false;

  bool news = false;

  bool specialtyDish = false;

  bool promotion = false;

  Widget get actions {
    return BrnTextAction(
      '发布',
      iconPressed: () {},
      themeData: BrnAppBarConfig(
          actionsStyle: BrnTextStyle(
              color: Colors.white, fontSize: Sizes.default16, fontWeight: FontWeight.normal)),
    );
  }

  double get leftWidth {
    return Sizes.default90;
  }

  double get rowHeight {
    return Sizes.default60;
  }

  TextSpan get requiredSpan {
    return TextSpan(text: ' *', style: StylesUtils.customTextStyle(color: ColorsUtils.colorFf0));
  }

  @override
  void initState() {
    super.initState();
    types.add(BrnMultiDataPickerEntity(text: '小馄饨类', value: 1));
    types.add(BrnMultiDataPickerEntity(text: '中馄饨类', value: 2));
    types.add(BrnMultiDataPickerEntity(text: '大馄饨类', value: 3));
    types.add(BrnMultiDataPickerEntity(text: '汤粉面类', value: 4));
    types.add(BrnMultiDataPickerEntity(text: '炒粉/面/饭', value: 5));
    types.add(BrnMultiDataPickerEntity(text: '大馄饨类', value: 6));
    types.add(BrnMultiDataPickerEntity(text: '配菜小吃', value: 7));
    types.add(BrnMultiDataPickerEntity(text: '糖水类', value: 8));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('商品管理', actions: actions),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              height: Sizes.default50,
              alignment: Alignment.centerLeft,
              padding: const EdgeInsets.symmetric(horizontal: Sizes.default15),
              child: Text('基本信息',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color797, fontSize: Sizes.default13)),
            ),
            Container(
              padding: const EdgeInsets.symmetric(
                  vertical: Sizes.default10, horizontal: Sizes.default15),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        width: leftWidth,
                        alignment: Alignment.topLeft,
                        child: Text.rich(TextSpan(
                            text: '商品图片',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                            children: [requiredSpan])),
                      ),
                      Expanded(
                          child: Container(
                        alignment: Alignment.centerLeft,
                        child: Wrap(
                          spacing: Sizes.default10,
                          runSpacing: Sizes.default10,
                          children: [
                            ...imgs.map((e) => Stack(
                                  children: [
                                    GFImageOverlay(
                                      image: FileImage(File(e.path)),
                                      width: 105,
                                      height: 105,
                                      borderRadius: BorderRadius.circular(Sizes.default5),
                                    ),
                                    Positioned(
                                        top: 10,
                                        right: 10,
                                        child: IconButton(
                                          onPressed: () {
                                            setState(() {
                                              imgs.remove(e);
                                            });
                                          },
                                          icon: Icon(AntdIcons.delete,
                                              size: Sizes.default20,
                                              color: ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.colorFf0)),
                                        ))
                                  ],
                                )),
                            InkWell(
                              onTap: () {
                                ToolsUtils.openCupertinoModalPopup(
                                    context, setMediaImg, setMediaImg);
                              },
                              child: Container(
                                width: 105,
                                height: 105,
                                decoration: BoxDecoration(
                                    color: ColorsUtils.rgba(247, 247, 247, 1),
                                    borderRadius: BorderRadius.circular(Sizes.default5)),
                                alignment: Alignment.center,
                                child: ToolsUtils.getUrlSvg(
                                    'https://cdn7.axureshop.com/demo/1525603/images/发布商品_单品/u1046.svg',
                                    width: 24,
                                    height: 20),
                              ),
                            )
                          ],
                        ),
                      ))
                    ],
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '名称',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '如柠檬茶',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.text,
                            onChanged: (String content) {},
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '商品分类',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('请选择分类',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              ToolsUtils.openDataPicker(context, types, (selectedIndexList) {
                                // int index = selectedIndexList[0];
                                // BrnMultiDataPickerEntity entity = types[index];
                                setState(() {});
                              });
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                text: '商品编号',
                                style: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default15, color: ColorsUtils.color333),
                              ),
                            )),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '例如A0179281',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.text,
                            onChanged: (String content) {},
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '过期日期',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('商超类商品过期日期',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              ToolsUtils.openDatePicker(context,
                                  onConfirm: (DateTime dateTime, List<int> selectedIndex) {
                                BrnToast.show("onConfirm:  $dateTime   $selectedIndex", context);
                              });
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('单点不配送',
                            style: StylesUtils.customTextStyle(
                                fontSize: Sizes.default15, color: ColorsUtils.color333)),
                        GFToggle(
                          onChanged: (bool? val) {
                            setState(() {
                              delivery = val!;
                            });
                          },
                          value: delivery,
                          type: GFToggleType.ios,
                          boxShape: BoxShape.circle,
                          enabledTrackColor: ColorsUtils.rgba(255, 110, 83, 1),
                          enabledThumbColor: Colors.white,
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              height: Sizes.default50,
              alignment: Alignment.centerLeft,
              padding: const EdgeInsets.symmetric(horizontal: Sizes.default15),
              child: Text('商品描述',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color797, fontSize: Sizes.default13)),
            ),
            Container(
              padding: const EdgeInsets.symmetric(
                  vertical: Sizes.default10, horizontal: Sizes.default15),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                          width: leftWidth,
                          alignment: Alignment.centerLeft,
                          child: Text(
                            '商品类型',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                          ),
                        ),
                        Expanded(
                            child: Container(
                          alignment: Alignment.centerLeft,
                          child: Wrap(
                            spacing: Sizes.default15,
                            alignment: WrapAlignment.start,
                            crossAxisAlignment: WrapCrossAlignment.center,
                            children: [
                              InkWell(
                                onTap: () {
                                  setState(() {
                                    meal = true;
                                  });
                                },
                                child: Container(
                                  alignment: Alignment.center,
                                  constraints: const BoxConstraints.expand(
                                      width: 75, height: Sizes.default30),
                                  decoration: changeBoxDecoration(meal),
                                  child: Text(
                                    '单品',
                                    style: meal
                                        ? StylesUtils.customTextStyle(color: ColorsUtils.colorFf6)
                                        : StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                  ),
                                ),
                              ),
                              InkWell(
                                onTap: () {
                                  setState(() {
                                    meal = false;
                                  });
                                },
                                child: Container(
                                  alignment: Alignment.center,
                                  constraints: const BoxConstraints.expand(
                                      width: 75, height: Sizes.default30),
                                  decoration: changeBoxDecoration(!meal),
                                  child: Text('套餐',
                                      style: !meal
                                          ? StylesUtils.customTextStyle(color: ColorsUtils.colorFf6)
                                          : StylesUtils.customTextStyle(
                                              color: ColorsUtils.color333)),
                                ),
                              ),
                            ],
                          ),
                        ))
                      ],
                    ),
                  ),
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        width: leftWidth,
                        alignment: Alignment.centerLeft,
                        child: Text(
                          '描述',
                          style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                        ),
                      ),
                      Expanded(
                          child: BrnInputText(
                        borderRadius: Sizes.default10,
                        borderColor: ColorsUtils.rgba(247, 247, 247, 1),
                        bgColor: ColorsUtils.rgba(247, 247, 247, 1),
                        minLines: 2,
                        maxLength: 200,
                        minHeight: 105,
                        padding: const EdgeInsets.all(Sizes.default10),
                        hint: '请输入描述',
                        autoFocus: false,
                      ))
                    ],
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '主料',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '如鸡肉',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.text,
                            onChanged: (String content) {},
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '口味',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '如微辣',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.text,
                            onChanged: (String content) {},
                          ),
                        ))
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                          width: leftWidth,
                          alignment: Alignment.centerLeft,
                          child: Text(
                            '制作时长',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                          ),
                        ),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '请输入时长',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.text,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('min',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              height: Sizes.default50,
              alignment: Alignment.centerLeft,
              padding: const EdgeInsets.symmetric(horizontal: Sizes.default15),
              child: Text('规格属性',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color797, fontSize: Sizes.default13)),
            ),
            Container(
              padding: const EdgeInsets.symmetric(
                  vertical: Sizes.default10, horizontal: Sizes.default15),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                text: meal ? '商品规格' : '套餐规格',
                                style: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default15, color: ColorsUtils.color333),
                              ),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('添加规格0/5',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              Get.toNamed(meal ? RouteGet.productStandards : RouteGet.productMeal);
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '添加属性',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('添加属性',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              Get.toNamed(RouteGet.productAttribute);
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(
                                text: '价格',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                children: [requiredSpan]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '请输入金额',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('￥',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(
                                text: '库存数量',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                children: [requiredSpan]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '1-99999',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('份',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(
                                text: '打包费',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                children: [requiredSpan]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default10),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '0-99',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('￥/份',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              height: Sizes.default50,
              alignment: Alignment.centerLeft,
              padding: const EdgeInsets.symmetric(horizontal: Sizes.default15),
              child: Text('限时限量',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color797, fontSize: Sizes.default13)),
            ),
            Container(
              padding: const EdgeInsets.symmetric(
                  vertical: Sizes.default10, horizontal: Sizes.default15),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('是否限时开售',
                            style: StylesUtils.customTextStyle(
                                fontSize: Sizes.default15, color: ColorsUtils.color333)),
                        GFToggle(
                          onChanged: (bool? val) {
                            setState(() {
                              timeLimit = val!;
                            });
                          },
                          value: timeLimit,
                          type: GFToggleType.ios,
                          boxShape: BoxShape.circle,
                          enabledTrackColor: ColorsUtils.rgba(255, 110, 83, 1),
                          enabledThumbColor: Colors.white,
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('是否限量供应',
                            style: StylesUtils.customTextStyle(
                                fontSize: Sizes.default15, color: ColorsUtils.color333)),
                        GFToggle(
                          onChanged: (bool? val) {
                            setState(() {
                              limited = val!;
                            });
                          },
                          value: limited,
                          type: GFToggleType.ios,
                          boxShape: BoxShape.circle,
                          enabledTrackColor: ColorsUtils.rgba(255, 110, 83, 1),
                          enabledThumbColor: Colors.white,
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              height: Sizes.default50,
              alignment: Alignment.centerLeft,
              padding: const EdgeInsets.symmetric(horizontal: Sizes.default15),
              child: Text('新品促销',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color797, fontSize: Sizes.default13)),
            ),
            Container(
              padding: const EdgeInsets.symmetric(
                  vertical: Sizes.default10, horizontal: Sizes.default15),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('是否新品',
                            style: StylesUtils.customTextStyle(
                                fontSize: Sizes.default15, color: ColorsUtils.color333)),
                        GFToggle(
                          onChanged: (bool? val) {
                            setState(() {
                              news = val!;
                            });
                          },
                          value: news,
                          type: GFToggleType.ios,
                          boxShape: BoxShape.circle,
                          enabledTrackColor: ColorsUtils.rgba(255, 110, 83, 1),
                          enabledThumbColor: Colors.white,
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('是否招牌菜',
                            style: StylesUtils.customTextStyle(
                                fontSize: Sizes.default15, color: ColorsUtils.color333)),
                        GFToggle(
                          onChanged: (bool? val) {
                            setState(() {
                              specialtyDish = val!;
                            });
                          },
                          value: specialtyDish,
                          type: GFToggleType.ios,
                          boxShape: BoxShape.circle,
                          enabledTrackColor: ColorsUtils.rgba(255, 110, 83, 1),
                          enabledThumbColor: Colors.white,
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('是否促销',
                            style: StylesUtils.customTextStyle(
                                fontSize: Sizes.default15, color: ColorsUtils.color333)),
                        GFToggle(
                          onChanged: (bool? val) {
                            setState(() {
                              promotion = val!;
                            });
                          },
                          value: promotion,
                          type: GFToggleType.ios,
                          boxShape: BoxShape.circle,
                          enabledTrackColor: ColorsUtils.rgba(255, 110, 83, 1),
                          enabledThumbColor: Colors.white,
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  BoxDecoration changeBoxDecoration([bool isActive = true]) {
    if (isActive) {
      return BoxDecoration(
          color: ColorsUtils.rgba(255, 238, 238, 1),
          borderRadius: BorderRadius.circular(Sizes.default15),
          border: Border.all(color: ColorsUtils.rgba(255, 110, 83, 1)));
    }
    return BoxDecoration(
      color: ColorsUtils.rgba(245, 245, 245, 1),
      borderRadius: BorderRadius.circular(Sizes.default15),
    );
  }

  void setMediaImg(List<Media> res) {
    setState(() {
      imgs.addAll(res);
    });
  }
}

class _ProductInfo {
  /// 商品图片
  late List<Media> imsg;

  /// 名称
  late String name;

  /// 分类
  late int classify;

  /// 商品编号
  late String code;

  /// 过期日期
  late String expiredDate;

  /// 单点不配送
  late bool delivery;

  /// 商品类型
  late int type;

  /// 描述
  late String describe;

  /// 主料
  late String ingredient;

  /// 口味
  late String taste;

  /// 制作时长
  late int makeTime;
}
